/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : home.js                                 
*  Description  : 클럽개별메인 
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-06-14  이윤노    Created.  
*  2012-06-14  이윤노    Complete.    
*******************************************************************************/

jQuery(function($){
	
	//진행상활
	function clsRoundState(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "진행상황을 선택하십시요."			
		}
		
		this._init();
	}
	
	clsRoundState.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(0) td input:radio");
			this._HTMLDom = {
				"$layer": $layer
			}
			$layer.attr("id","rdoState").attr("name","rdoState").click(function(){
				setTimeout(function(){
					$layer.eq(0).prop("checked",true);
				}, 50);
			});
			//$layer.attr("id","rdoState").attr("name","rdoState").attr("disabled",false);
			this._HTMLDom["$layer"].eq(0).prop("checked",true);
		}
		, setValue: function(val){
			var idx = 0;
			if(val == "D") idx=0;
			else if(val == "C") idx=1;
			else if(val =="A") idx=2;
			this._HTMLDom["$layer"].eq(idx).prop("checked",true);
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.index($layer.filter(":checked"));
		}
		, isValid: function(){
			if(this.getValue()==-1){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	//노출여부
	function clsRoundOpen(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "노출종류를 선택하십시요."
		}
		
		this._init();
	}
	
	clsRoundOpen.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(1) td input:radio");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.attr("id","rdoOpen").attr("name","rdoOpen");
			this._HTMLDom["$layer"].eq(0).prop("checked",true);	
		}
		, setValue: function(val){
			var idx = 0;
			if(val=="Y") idx=0;
			else if(val=="N") idx=1;
			this._HTMLDom["$layer"].eq(idx).prop("checked",true);
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.index($layer.filter(":checked"));
		}
		, isValid: function(){
			if(this.getValue()==-1){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	//라운드일자
	function clsRoundDate(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "라운드일자를 선택하십시요."
		}
		
		this._init();
	}
	
	clsRoundDate.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(2) td");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.find("img").remove();
			
			var n = new Date();
			n.setDate(n.getDate()+1);
			
			$layer.find("input:text").css("margin-right","10px").attr({
				"readonly": "readonly"
				, "id": "idRoundDate"
				, "value": ""
			}).datepicker({
				showOn: "both"
				, buttonImage: _ROOT + "/images/btn/icon_calendar.gif"
				, buttonImageOnly: true
				, minDate : n
			});
		
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].find("input:text").val(getFormatDateYmd(val,"-"));
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"].find("input:text");
			return this._HTMLDom["$layer"].find("input:text").val();
		}
		, isValid: function(){
			if(this.getValue().length==0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
		
	//골프장코스
	function clsCourse(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "골프장코스를 입력하십시요."
		}
		
		this._init();
	}
	
	clsCourse.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(3) td input:text");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.empty();
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].val(val);
		}
		, getValue: function(){ 
			var $layer = this._HTMLDom["$layer"];
			return $layer.val();
		}
		, isValid: function(){
			if(this.getValue().trim().length==0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	//홀정보
	function clsHole(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "홀정보를 선택하십시요."
			, "_REGULAR": "홀정보에는 숫자만 입력하십시요."
		}
		
		this._init();
	}
	
	clsHole.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(4) td input:text");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.empty();
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].val(val);
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.val();
		}
		, isValid: function(){
			var reg = /[0-9]$/ig;	 
			
			if(this.getValue().trim().length==0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}else if(!reg.test(this.getValue())){
				this.errMsg = this._ERRMSG["_REGULAR"];
				return false;	
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	//모집인원
	function clsRecruit(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "모집인원을 입력하십시요."
			, "_REGULAR": "모집인원에는 숫자만 입력하십시요."
		}
		
		this._init();
	}
	
	clsRecruit.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(5) td input:text");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.empty();
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].val(val);
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.val();
		}
		, isValid: function(){
			var reg = /[0-9]$/ig;
			
			if(this.getValue().trim().length==0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}else if(!reg.test(this.getValue())){
				this.errMsg = this._ERRMSG["_REGULAR"];
				return false;	
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	//팀명,시간
	function clsTeam(){
		this._HTMLDom = null;
		this.listData = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "팀명을 입력해주십시요."
			, "_NOHOUR": "시간을 지정해주십시요."
			, "_NOMINUTE": "분을 지정해주십시요."
		}
		
		this._init();
	}
	
	clsTeam.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(6)");			
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("p.team_plus")
			}
			
			this.initSelect();
			
			$layer.find("p.team_plus").remove();
		}		
		, initSelect: function(){
			$layer = this._HTMLDom["$layer"];
			
			var hour = $layer.find("select#hour");			
			var minute = $layer.find("select#minute");
			hour.find("option").not(":first-child").remove();
			minute.find("option").not(":first-child").remove();
			
			for(var i=1;i<24;++i){
				hour.append("<option>" + (("00"+i).substrEx(-2)) +"</option");
			}
			for(var i=0;i<60;++i){
				minute.append("<option>" + (("00"+i).substrEx(-2)) + "</option>");
			}
		}		
		, $getBtnTeamAdd: function(){
			return this._HTMLDom["$layer"].find("a img[alt=팀추가]");
		}
		, $getBtnTeamRemove: function(){
			return this._HTMLDom["$layer"].find("a.del img[alt=팀삭제]");
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			
			var returnData = "";
			var pre = "!@#";
			
			for(var i=0;i<$layer.find("input:text").length;++i){
				if(returnData != "") returnData += pre;	
				returnData += $layer.find("input:text").eq(i).val() + pre
				 + $layer.find("select#hour").eq(i).val() + pre
				 + $layer.find("select#minute").eq(i).val() 
			}
			
			return returnData;
		}
		, setValue: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
						
			for(var i=0;i<this.listData.length-1;++i){
				this.append();
			}
		
			$layer.find("#minute").each(function(n){					
				var $hour = Number(thisClass.listData[n]["라운드시간"]);
				var $min = Number(thisClass.listData[n]["라운드분"]);
				
				$layer.find("input:text").eq(n).val(thisClass.listData[n]["팀명"]);
				$layer.find("select#hour").eq(n).find("option").eq($hour).attr("selected","selected");
				$layer.find("select#minute").eq(n).find("option").eq($min+1).attr("selected","selected");
			});
		}
		, isValid: function(){
			var $layer = this._HTMLDom["$layer"];
			
			for(var i=0;i<$layer.find("input:text").length;++i){
				
				if($layer.find("input:text").eq(i).val().trim().length == 0){
					this.errMsg = this._ERRMSG["_NOVALUE"];
					return false;	
				}else if($layer.find("select#hour").eq(i).find("option:eq(0)").is(":selected")){
					this.errMsg = this._ERRMSG["_NOHOUR"];
					return false;	
				}else if($layer.find("select#minute").eq(i).find("option:eq(0)").is(":selected")){
					this.errMsg = this._ERRMSG["_NOMINUTE"];
					return false;		
				}
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
		, append: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			
			if($layer.find("p.team_plus").length < 19) {
				$layer.find("p.ft_r").before($element.clone(true));
			}else {
				alert("팀은 최대 20개까지만 추가하실 수 있습니다.");
			}	
		}
		, remove: function(idx){			
			$layer.find("p.team_plus").eq(idx).remove();
		}
	}
	
	//제목
	function clsTitle(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "라운드제목을 입력하십시요."
		}
		
		this._init();
	}
	
	clsTitle.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(8) td input:text");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.empty();
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].val(val);
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.val();
		}
		, isValid: function(){
			if(this.getValue().trim().length==0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	//내용
	function clsContents(){
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "내용을 입력하십시요."
		}
		
		this._init();
	}
	
	clsContents.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.club_creat table tbody tr:eq(9) td textarea");
			this._HTMLDom = {
				"$layer": $layer
			}			
			
			$layer.empty();
		}
		, setValue: function(val){
			this._HTMLDom["$layer"].val(val)
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.val();
		}
		, isValid: function(){
			if(this.getValue().trim().length==0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;
			}
			return true;
		}
		, getError: function(){
			return this.errMsg;
		}
		, focus: function(){
			this._HTMLDom["$layer"].focus();
		}
	}
	
	function clsComm()
	{
		this.clubRoundInfoRequest = null;		
		
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){
			this.clubRoundInfoRequest = {
				 "동호회키":null
				, "라운드키": null
				, "페이지": null				
			}
		}
//------------------------수정글정보조회------------------------//		
		, getClubRoundInfo: function(){
			var thisClass = this;
			var szClubSeq = this.clubRoundInfoRequest["동호회키"];
			var szRoundSeq = this.clubRoundInfoRequest["라운드키"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename":"getMyClubRoundInfo",
			}, {
				  "clubSeq": szClubSeq
				  ,"roundSeq": szRoundSeq
			}, function(ret){
				
				// callback and mapping			
				if(ret["msp"]["contents"]["items"]){
					
					var obj = ret["msp"]["contents"]["items"];
					var team = obj["roundInfo"]["roundTeamInfoList"][0]["items"];
					var arr = [];
					
					if(team){
												
						if(!team.length){
							team = new Array(team);
						}
						
						var user= [];
						
						//팀별정보
						for(var k=0;k<team.length;++k){
							
							user[k] = [];
							
							//팀별 사용자(최대4명) 정보
							for(var m=0;m<4;++m){
								var str = "assignedUser"+ (m+1) +"Info";
								if(team[k][str]){
									user[k][m]={
										"아이디": _util.nvl(team[k][str]["userId"])
										, "이미지": _util.nvl(team[k][str]["path"]) + _util.nvl(team[k][str]["saveFileName"])
										, "닉네임": _util.nvl(team[k][str]["nickname"])
										, "지역": _util.nvl(team[k][str]["region"])
										, "연령대": _util.nvl(team[k][str]["age"])
										, "성별": _util.nvl(team[k][str]["sex"])
										, "핸디": _util.nvl(team[k][str]["handi"])
										, "평타": _util.nvl(team[k][str]["average"])
									}								
								}
							}
							
							arr.push({
								"팀키": _util.nvl(team[k]["teamSeq"])
								, "팀명": _util.nvl(team[k]["teamName"])
								, "라운드시간": _util.nvl(team[k]["roundHour"])
								, "라운드분": _util.nvl(team[k]["roundMinute"])
								, "사람1": _util.nvl(user[k][0])
								, "사람2": _util.nvl(user[k][1])
								, "사람3": _util.nvl(user[k][2])
								, "사람4": _util.nvl(user[k][3])
							});
						}
					}
					
					//동호회목록
					thisClass.clubRoundInfo= {
						"동호회키": _util.nvl(obj["roundInfo"]["clubSeq"])
						, "닉네임": _util.nvl(obj["userMaster"]["nickname"])
						, "이미지": "http://192.168.0.82/images/board/default_50_50.gif"
						, "라운드키": _util.nvl(obj["roundInfo"]["roundSeq"])
						, "라운드일자": _util.nvl(obj["roundInfo"]["reservDate"])
						, "라운드요일": _util.nvl(obj["roundInfo"]["reservDay"])
						, "라운드시간": _util.nvl(obj["roundInfo"]["firstTime"])
						, "코스명": _util.nvl(obj["roundInfo"]["golfclubCourseInfo"])
						, "홀수": _util.nvl(obj["roundInfo"]["holeInfo"])
						, "라운드명": _util.nvl(obj["roundInfo"]["title"])
						, "모집팀수": _util.nvl(obj["roundInfo"]["totalTeamCnt"])
						, "모집인원수": _util.nvl(obj["roundInfo"]["totalMember"])
						, "신청인원수": _util.nvl(obj["roundInfo"]["requestedMemberCnt"])
						, "배정완료수": _util.nvl(obj["roundInfo"]["assignedMemberCnt"])
						, "라운딩진행상태": _util.nvl(obj["roundInfo"]["procStatus"]) //진행중(0),확정(1),마감(2)													
						, "작성일자": "20120630"
						, "작성시간": "2019"
						, "조회수": "256"
						, "신청상태": _util.nvl(obj["roundInfo"]["roundRequestUser"]["assignedStatus"])
						, "내용": _util.nvl(obj["roundInfo"]["detail"])
						, "노출여부": _util.nvl(obj["roundInfo"]["mainDispYn"])
						, "배정노출유무": _util.nvl(obj["roundInfo"]["assignStatusDispYn"])
						, "팀정보": _util.nvl(arr,[])
					};					
					
				}
			
				$(thisClass).trigger("evtFinishClubRoundInfo");
			});
		}
		, getClubRoundInfoData: function(){
			return this.clubRoundInfo;
		}
		, setClubRoundInfoRequest: function(key, val){			
			this.clubRoundInfoRequest[key] = val;
		}
		, getClubRoundInfoRequest: function(key){
			return this.clubRoundInfoRequest[key];
		}	
//------------------------ 라운드목록------------------------//	
//------------------------ 글등록/수정------------------------//		

		, InsertRoundData: function(arg){			
			var thisClass = this;
					
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
			var szRoundState = arg["진행상황"];
			var szRoundOpen = arg["노출여부"];
			var szRoundDate = arg["라운드일자"];
			var szCourse = arg["라운드코스"];
			var szHole = arg["홀정보"];
			var szRecruit = arg["모집인원"];
			var szTeam = document.objUtil.ajaxTrans(arg["팀정보"]);
			var szTitle = document.objUtil.ajaxTrans(arg["제목"]);
			var szContents = document.objUtil.ajaxTrans(arg["내용"]);
			
			var szModule = (szRoundSeq==""?"registClubRound":"updateClubRound");
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename": szModule
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq
				, "procStatus": szRoundState
				, "mainDispYn": szRoundOpen
				, "reservDate": szRoundDate
				, "golfclubCourseInfo": szCourse
				, "holeInfo": szHole
				, "totalMember": szRecruit
				, "title": szTitle
				, "detail": szContents
				, "roundTeamInfoStr": szTeam				
			}, function(ret){				
				// callback and mapping
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				//$(thisClass).trigger("evtFinishClubRoundSubmit", [resData]);
				
			},true);
			// ajax 끝
		}
//------------------------ 글등록------------------------//	
	}
	
	function clsControl()
	{
		this.club_seq = null;
		this.club_my = null;
		
		this.objComm = null;		
		this.objClubInfo = null
		this.objRole = null;
		this.objRoundState = null;
		this.objRoundOpen = null;
		this.objRoundDate = null;
		this.objCourse = null;
		this.objHole = null;
		this.objRecruit = null;
		this.objTeam = null;
		this.objTitle = null;
		this.objContents =null;
		
		this._init();
	}
	
	clsControl.prototype = {
		_init: function(){
			var member_id = document.objUtil.getCookie("member_id");
			this.club_seq = document.objUtil.getParam("club_seq");
			this.club_my = document.objUtil.getParam("club_my");
			this.round_seq = document.objUtil.getParam("round_seq");
			
			if(!member_id) {
				if(confirm("로그인 후 이용하여 주세요.")){
					_gf.goLogin();						
				}else{
					document.location.href = "../club/club.html";
				}
			}else if(!this.club_seq) {
				document.location.href = "../club/club.html";
			}
			
			this._preload();
			
			this.objComm = new clsComm();
			this.objRoundState = new clsRoundState();
			this.objRoundOpen = new clsRoundOpen();
			this.objRoundDate = new clsRoundDate();
			this.objCourse = new clsCourse();
			this.objHole = new clsHole();
			this.objRecruit = new clsRecruit();
			this.objTeam = new clsTeam();
			this.objTitle = new clsTitle();
			this.objContents = new clsContents();
			
			this._beforeStart();
			this._bind();
		}
		, _preload: function(){
			_gf.spinStart();
		}
		, _beforeStart: function(){
			var thisClass = this;
			this._permitStart = {
				
			}
			
			$.ajax({
				url: "js/self_club_top.js"
				, dataType: "script"
				, async: false
				, success: function(){
					
				}
				, error: function(){
					alert("error");
				}
			});
			
			_util.executeThread(function(){
				for(var k in thisClass._permitStart){
					if(!thisClass._permitStart[k]) return false;
				}
				
				return (_clubControl.getClubInfo().infoData);
			}, function(){				
				_gf.spinEnd();;
				thisClass._start();
			});	
		}
		, _role: function(){
			if(!this.objRole.isAdmin()){//0-일반회원, 1-가입대기회원, 9-탈퇴회원
				alert(this.objRole.getError());
				document.location.href = "home.html?club_seq=" + this.infoData["동호회키"];
			}
		}
		, _start: function(){		
			this.objClubInfo = _clubControl.getClubInfo();
			this.objRole = new clsRole(this.objClubInfo.infoData);
			this._role();

			//수정시
			if(this.round_seq){
				_gf.spinStart("조회중...");					
				this.objComm.setClubRoundInfoRequest("동호회키", this.club_seq);
				this.objComm.setClubRoundInfoRequest("라운드키", this.round_seq);					
				this.objComm.getClubRoundInfo();	
			}
		}
		, _bind: function(){
			var thisClass = this;
		
			//게시글 등록 완료이벤트
			$(this.objComm).bind("evtFinishClubRoundSubmit", function(event, resData){				
				alert(resData["메세지"]);				
				if(resData["응답코드"]){				
					_gf.spinEnd();					
					document.location.href = "club_admin_rd.html" + thisClass.returnParam();
				}			
			});
			
			//라운드정보 조회 완료 이벤트 
			$(this.objComm).bind("evtFinishClubRoundInfo", function(){
				var thisData = thisClass.objComm.getClubRoundInfoData();
				
				thisClass.objRoundState.setValue(thisData["라운딩진행상태"]);
				thisClass.objRoundOpen.setValue(thisData["노출여부"]);
				thisClass.objRoundDate.setValue(thisData["라운드일자"]);
				thisClass.objCourse.setValue(thisData["코스명"]);
				thisClass.objHole.setValue(thisData["홀수"]);
				thisClass.objRecruit.setValue(thisData["모집인원수"]);
				thisClass.objTeam.setValue(thisData["팀정보"]);
				thisClass.objTitle.setValue(thisData["라운드명"]);
				thisClass.objContents.setValue(thisData["내용"]);
				_gf.spinEnd();
			});
						
			//확인
			$("div#container p.btn_center img[alt=확인]").click(function(event){
				
				var szClubSeq = thisClass.club_seq;
				var szRoundSeq = thisClass.round_seq;
				var szRoundState = thisClass.objRoundState.getValue();
				var szRoundOpen = thisClass.objRoundOpen.getValue();
				var szRoundDate = thisClass.objRoundDate.getValue();
				var szCourse = thisClass.objCourse.getValue();
				var szHole = thisClass.objHole.getValue();
				var szRecruit = thisClass.objRecruit.getValue();
				var szTeam = thisClass.objTeam.getValue();
				var szTitle = thisClass.objTitle.getValue();
				var szContents = thisClass.objContents.getValue();
						
				if(!thisClass.objRoundState.isValid()){
					alert(thisClass.objRoundState.getError());	
					return;
				}else if(!thisClass.objRoundOpen.isValid()){
					alert(thisClass.objRoundOpen.getError());
					return;
				}else if(!thisClass.objRoundDate.isValid()){
					alert(thisClass.objRoundDate.getError());
					return;
				}else if(!thisClass.objRoundDate.isValid()){
					alert(thisClass.objRoundDate.getError());
					return;
				}else if(!thisClass.objCourse.isValid()){
					alert(thisClass.objCourse.getError());
					return;
				}else if(!thisClass.objHole.isValid()){
					alert(thisClass.objHole.getError());
					return;
				}else if(!thisClass.objRecruit.isValid()){
					alert(thisClass.objRecruit.getError());
					return;
				}else if(!thisClass.objTeam.isValid()){
					alert(thisClass.objTeam.getError());	
					return;
				}else if(!thisClass.objTitle.isValid()){
					alert(thisClass.objTitle.getError());
					return;
				}else if(!thisClass.objContents.isValid()){
					alert(thisClass.objContents.getError());
					return;
				}
			
				var submitData = {
					"동호회키": szClubSeq
					, "라운드키": szRoundSeq
					, "진행상황": (szRoundState=="0"?"P":"C") //0(P)-진행,1(C)-확정,2(D)-마감
					, "노출여부": (szRoundOpen=="0"?"Y":"N") //0-홈노출,1-동호회노출
					, "라운드일자": szRoundDate.replace(/\-/g,"")
					, "라운드코스": szCourse
					, "홀정보": szHole
					, "모집인원": szRecruit
					, "팀정보": szTeam
					, "제목": szTitle
					, "내용": szContents
				}
				
				thisClass.objComm.InsertRoundData(submitData);
			});
			
			//취소
			$("div#container p.btn_center img[alt=취소]").click(function(event){
				document.location.href = "club_admin_rd.html" + thisClass.returnParam();
			});
			
			//팀추가
			this.objTeam.$getBtnTeamAdd().click(function(event){
				thisClass.objTeam.append();
			})
			//팀삭제
			this.objTeam.$getBtnTeamRemove().live("click",function(event){
				var $layer = thisClass.objTeam._HTMLDom["$layer"];
				var $element = thisClass.objTeam._HTMLDom["$element"];
				
				var idx = thisClass.objTeam.$getBtnTeamRemove().index($(this));
				
				if(thisClass.round_seq){
					if(thisClass.objTeam.listData.length-2 >= idx){
						if(thisClass.objTeam.listData[idx+1]["사람1"]){
							if(thisClass.objTeam.listData[idx+1]["사람1"]["닉네임"]){
								alert("이미 배정된 회원이 있습니다.\n해당 팀의 회원 배정을 취소 후 다시 시도하여 주세요.");	
								return;
							}else{
								thisClass.objTeam.listData.splice(idx+1,1);	
							}
						}
					}
				}
				
				thisClass.objTeam.remove(idx);
			})
		}
		, returnParam: function(){
			return "?club_seq="+ this.club_seq;	
		}	
	}
	
	document.objControl = new clsControl();
});
